pub mod message;

pub mod endpoint;

pub type Result<T> = std::result::Result<T, Error>;

/// 通用错误类型.
#[derive(Debug)]
pub struct Error {
    info: String,
}

impl Error {
    pub fn new(info: String) -> Self {
        Self { info }
    }
}

impl std::fmt::Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.info)
    }
}

impl<E: std::error::Error> From<E> for Error {
    fn from(error: E) -> Self {
        Self {
            info: format!("{}", error),
        }
    }
}
